$.ajax({
    url: 'http://127.0.0.1:8086/life',
    type: 'GET',
    dataType: 'json',
    success: function(response) {
        var data = response.data[0];
        var xAxisData = []; // x轴数据数组
        var seriesData = [
            { name: '吃饭', type: 'bar', stack: '总量', data: [] },
            { name: '睡觉', type: 'bar', stack: '总量', data: [] },
            { name: '工作', type: 'bar', stack: '总量', data: [] },
            { name: '学习', type: 'bar', stack: '总量', data: [] },
            { name: '其他', type: 'bar', stack: '总量', data: [] }
        ]; // 数据系列数组
  
        for (var key in data) {
            xAxisData.push(key);
            seriesData[0].data.push(data[key]['吃饭']);
            seriesData[1].data.push(data[key]['睡觉']);
            seriesData[2].data.push(data[key]['工作']);
            seriesData[3].data.push(data[key]['学习']);
            seriesData[4].data.push(data[key]['其他']);
        }
  
        // 渲染图表
        var myChart = echarts.init(document.getElementById('ec03_barV_timeDistribute'));
        myChart.setOption({
            title: {
                text: '',
        
                textStyle: {
                  fontSize: 10,    
                  color: '#fff' // 修改字体颜色
                          }
            },
            legend: {
                data: ['吃饭', '睡觉', '工作', '学习', '其他'],
                textStyle: {
                            color: '#fff' // 修改字体颜色
                          }
            },
            xAxis: {
                type: 'category',
                data: xAxisData
            },
            yAxis: {
             name:'时间/小时',
                type: 'value',
            },
            series: seriesData
        });
    },
    error: function(xhr, status, error) {
        console.error(error);
    }
  });